//
//  SqliteManager+API.m
//  ZhuShou
//
//  Created by Dejun Liu on 15/11/4.
//  Copyright © 2015年 jw. All rights reserved.
//

#import "SqliteManager+API.h"
#import "SqliteManager+Base.h"

@implementation SqliteManager (API)

- (NSArray *) getAPIs
{
    @synchronized(self)
    {
        NSString *sql = [NSString stringWithFormat:@"select * from servers"];
        FMResultSet *rs = [self executeQueryWithSql:sql];
        
        NSMutableArray *array = [NSMutableArray array];
        ZSAPI *model = nil;
        if(rs != nil)
        {
            while ([rs next]) {
                model = [[ZSAPI alloc]init];
                model.sid = [rs stringForColumn:@"sid"];
                model.sprotocal = [rs stringForColumn:@"sprotocal"];
                model.sip = [rs stringForColumn:@"sip"];
                model.sport = [rs stringForColumn:@"sport"];
                model.stype = [rs stringForColumn:@"stype"];
                model.senv = [rs stringForColumn:@"senv"];
                model.sorder = [rs intForColumn:@"sorder"];
                
                [array addObject:model];
            }
            [rs close];
        }
        return array;
    }
}

@end
